<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>学生的所有科目</title>
</head>
<body>

	<table id="sample-table-1"
		class="table table-striped table-bordered table-hover">
		<tr>
			<th>科目ID</th>
			<th>科目</th>
			<th>简介</th>
			<th>考试次数</th>
			<th>考试时长(分钟)</th>
			<th>考试总分</th>
			<th>考试状态</th>
			<th>是否已参考</th>
			<th>考试成绩</th>
			<th>操作</th>
		</tr>
		<c:forEach items="${subjectList }" var="list">
			<tr>
				<td>${list.sub_id }</td>
				<td>${list.name }</td>
				<td width="200" style="line-height: 20px;">${list.description }</td>
				<td>${list.test_count }</td>
				<td>${list.total_time }</td>
				<td>${list.total_score }</td>
				<td><c:choose>
						<c:when test="${list.status==0 }">
							<span class="label label-failure arrowed-in arrowed-in-right">未开启</span>
						</c:when>
						<c:otherwise>
							<span class="label label-success arrowed-in arrowed-in-right">开启</span>
						</c:otherwise>
					</c:choose></td>
				<td><c:choose>
						<c:when test="${not empty list.score }">
							<span class="label label-success arrowed-in arrowed-in-right">已考</span>
						</c:when>
						<c:otherwise>
							<span class="label label-failure arrowed-in arrowed-in-right">未考</span>
						</c:otherwise>
					</c:choose></td>
				<td>${list.score }</td>
				<td><c:choose>
						<c:when test="${list.status==1 }">
							<c:choose>
								<c:when test="${not empty list.score }">
									<button class="btn btn-xs btn-success">
										<span scoreId="${list.scoreId}"
											class="bigger-110 showScoreBtn"> 查看成绩表</span> <i
											class="ace-icon fa fa-arrow-right icon-on-right"></i>
									</button>
								</c:when>
								<c:otherwise>
									<button class="btn btn-xs btn-success">
										<span class="bigger-110"><a
											href="toTest/${list.sub_id }">进入考试</a></span> <i
											class="ace-icon fa fa-arrow-right icon-on-right"></i>
									</button>
								</c:otherwise>
							</c:choose>
						</c:when>
					</c:choose></td>
			</tr>
		</c:forEach>
	</table>
	<!-- 显示成绩-模态框 -->
	<div class="modal fade" id="showScoreModal" tabindex="-1" role="dialog"
		aria-labelledby="showTestModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="myModalLabel">查看成绩单</h4>
				</div>
				<div class="modal-body">
					<label>用户名：&nbsp;&nbsp;</label><span id="userName"></span><br /> <label>科目名：&nbsp;&nbsp;</label><span
						id="subjectName"></span><br /> <label>考试时间：&nbsp;&nbsp;</label><span
						id="examTime"></span><br /> <label>得分：&nbsp;&nbsp;</label><span
						id="score"></span><br />
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button id="scorePrint" type="button" class="btn btn-primary">打印</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal -->
	</div>
	<script type="text/javascript">
		$(function() {
			$('.showScoreBtn').click(function() {
				var scoreId = $(this).attr('scoreId');
				$.ajax({
					type : 'POST',
					url : '${contextPath}/teacher/showScore',
					data : {
						scoreId : scoreId
					},
					dateType : "json",
					success : function(data) {

						$('#userName').text(data.userName);
						$('#subjectName').text(data.subjectName);
						$('#examTime').text(data.examTime);
						$('#score').text(data.score);
					}
				});
				$('#showScoreModal').modal('show');
			});
			//使用jqprint打印modal框内的内容
			$('#scorePrint').click(function() {
				$('#showScoreModal .modal-body').jqprint();
			});
		})
	</script>
</body>
</html>